package com.zuo.demo01.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class FileUtil {



    public static String rename(String old_name){
        String suffixName = old_name.substring(old_name.lastIndexOf("."));
        //生成文件名称通用方法
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
        Random r = new Random();
        StringBuilder tempName = new StringBuilder();
        tempName.append(sdf.format(new Date())).append(r.nextInt(100)).append(suffixName);
        String new_name = tempName.toString();
        return new_name;
    }

    public static String randomName(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
        Random r = new Random();
        StringBuilder tempName = new StringBuilder();
        tempName.append(sdf.format(new Date())).append(r.nextInt(100));
        String name = tempName.toString();
        return name;
    }


}
